﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FigureDraw
{
    public class Shadow : EffectShape
    {
        
        public Shadow(CommonShape shape)
        {
            this.shape = shape;
            
        }
        public override CommonShape UnEffect()
        {
            return shape;
        }
        public override void DrawToDevice(Form f)
        {
            int red;
            int green;
            int blue;
            int linewid;

            System.Drawing.Point DiemDau;
            System.Drawing.Point DiemCuoi;
            if (this.StorageDevice == null)
            {
                red = this.shape.getRColor();
                green = this.shape.getGColor();
                blue = this.shape.getBColor();
                linewid = this.shape.getLineWidth();

                this.setColor(red, green, blue);
                this.setLineWidth(linewid);

                DiemDau = new System.Drawing.Point(this.shape.BeginPoint.X, this.shape.BeginPoint.Y);
                DiemCuoi = new System.Drawing.Point(this.shape.EndPoint.X, this.shape.EndPoint.Y);
                this.BeginPoint = this.shape.BeginPoint;
                this.EndPoint = this.shape.EndPoint;
                this.StorageDevice = GetStorageDevice();
            }
            else
            {
                red = this.getRColor();
                green = this.getGColor();
                blue = this.getBColor();
                linewid = this.getLineWidth();

                this.shape.setColor(red, green, blue);
                this.shape.setLineWidth(linewid);

                DiemDau = new System.Drawing.Point(this.BeginPoint.X, this.BeginPoint.Y);
                DiemCuoi = new System.Drawing.Point(this.EndPoint.X, this.EndPoint.Y);
                this.shape.BeginPoint = this.BeginPoint;
                this.shape.EndPoint = this.EndPoint;
                this.shape.StorageDevice = GetStorageDevice();
            }

            
            System.Drawing.Point DiemDauBong = new System.Drawing.Point(DiemDau.X + 10, DiemDau.Y + 10);
            System.Drawing.Point DiemCuoiBong = new System.Drawing.Point(DiemCuoi.X + 10, DiemCuoi.Y + 10);
            
              this.shape.setColor(183, 183, 183);
                
            
                this.shape.BeginPoint = DiemDauBong;
                this.shape.EndPoint = DiemCuoiBong;
                this.shape.DrawToDevice(f);

                this.shape.setColor(red, green, blue);
                this.shape.BeginPoint = DiemDau;
                this.shape.EndPoint = DiemCuoi;
                this.shape.DrawToDevice(f);


                
                
            
        }

        public override string ToString()
        {
            return shape.ToString() + "Shadow";
        }
    }
}
